package cn.snorlaxzjt.LBSserver.controller;


import cn.snorlaxzjt.LBSserver.business.FriendBusiness;
import cn.snorlaxzjt.LBSserver.common.BusinessCode;
import cn.snorlaxzjt.LBSserver.common.Result;
import cn.snorlaxzjt.LBSserver.po.body.FriendBody;
import cn.snorlaxzjt.LBSserver.po.page.FriendPage;
import cn.snorlaxzjt.LBSserver.po.page.PersonalInfoPage;
import cn.snorlaxzjt.LBSserver.po.page.ResultPage;
import io.swagger.annotations.Api;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("api/friend")
@Api(value = "momentController")
public class FriendsController {


    @Resource
    private FriendBusiness friendBusiness;


    @PostMapping("/add")
    public Result<Map<String,String>> follow(@Param(value = "friendId")Integer friendId) {
        return friendBusiness.follow(friendId);
    }

    @PostMapping("/del")
    public Result<Map<String,String>> cancelFollow(@Param(value = "friendId")Integer friendId) {
        return friendBusiness.cancelFollow(friendId);
    }

    @GetMapping("/getFriends")
    public Result<FriendPage> getMyFriends() {
        return BusinessCode.SUCCESS.toResult(friendBusiness.getMyFriends());
    }

    @GetMapping("/personalInfo")
    public Result<PersonalInfoPage> getPersonalInfoById(@Param(value = "id") Integer id){
        return friendBusiness.getPersonalInfoById(id);
    }
}
